﻿using Echo.Context.UltiProNet.Contexts;
using Echo.Core.TestAbstraction.WebUITest.MbUnit;
using Echo.Models.UltiProNet;
using Echo.Models.UltimateSoftware.WebUITest.MbUnit;
using MbUnit.Framework;

////*************************************************************************************************************************************
////Created by:Yesenia Sosa
////Date created:10/2/2012
////Modified by: 
////Date modified: 
////Reason: 
////ULTI-75062  Echo Conversion - Business Rules - RISUIER calc
////*************************************************************************************************************************************

namespace Echo.Automation.Compliance.BusinessRules.Taxes
{
    [TestFixture]
    [Header("Config")]
    [Config(".NET")]
    [Author("Yesenia Sosa", "yesenia_sosa@ultimatesoftware.com")]
    [Category("Taxes")]
    [Category("Business Rules")]
    public class RISUIERCalc : MbUnitAutomatedTest
    {
        UltiPro UltiPro;
        UltiProDatabaseContext Database;

        [FixtureSetUp]
        public void FixtureSetUp()
        {
            #region Given that UltiPro is launched and I am logged in as MerrillG
            UltiPro = Launch<UltiPro>();
            Database = Init<UltiProDatabaseContext>();
            Database.Company = ConfigDatabase("ULTIPRO_CALENDAR");
            UltiPro.Pages.Login.LoginAs("merrillg", "password", Config.LanguageCode);
            UltiPro.Pages.CompanySelector.ChooseCompanies("CALEN", "C0014");
            #endregion

            #region When I navigate to BusinessRules > Taxes
            UltiPro.Menu.SystemConfiguration.Click(x => x.BusinessRules);
            UltiPro.Pages.BusinessRulesSummary.BusinessRulesSummaryGrid.Find(x => x.BusinessRulesNameFilter, FilterType.Is, "Taxes");
            UltiPro.Pages.BusinessRulesSummary.BusinessRulesSummaryGrid.Row(grid => grid.BusinessRulesLink, "Taxes").Click(x => x.BusinessRulesLink);
            #endregion

            #region Then I look for RISUIER taxes
            UltiPro.Pages.BusinessRuleDetail.BusinessRuleDetailGrid.Find(x => x.CodeFilter, FilterType.Is, "RISUIER");
            UltiPro.Pages.BusinessRuleDetail.BusinessRuleDetailGrid.Row(grid => grid.Code, "RISUIER",
                                                                        grid => grid.Company, "Web Payroll Company").Click(x => x.Code);
            #endregion
        }

        [Test]
        public void Check1500AdditionalWageBase()
        {
            #region Then I turn on the $1500 Additional Wage Base check box and verify it saves
            UltiPro.Pages.TaxCodeContributionRate.NotSelected(x => x.AdditionalWageBaseCheckBox);
            UltiPro.Pages.TaxCodeContributionRate.Click(x => x.AdditionalWageBaseCheckBox);
            UltiPro.Pages.TaxCodeContributionRate.ButtonBar.Click(x => x.Save);
            UltiPro.Pages.BusinessRuleDetail.BusinessRuleDetailGrid.Row(grid => grid.Code, "RISUIER",
                                                                        grid => grid.Company, "Web Payroll Company").Click(x => x.Code);
            UltiPro.Pages.TaxCodeContributionRate.Selected(x => x.AdditionalWageBaseCheckBox);
            #endregion

            #region And Then I turn off the $1500 Additional Wage Base check box and verify it saves
            UltiPro.Pages.TaxCodeContributionRate.Click(x => x.AdditionalWageBaseCheckBox);
            UltiPro.Pages.TaxCodeContributionRate.ButtonBar.Click(x => x.Save);
            UltiPro.Pages.BusinessRuleDetail.BusinessRuleDetailGrid.Row(grid => grid.Code, "RISUIER",
                                                            grid => grid.Company, "Web Payroll Company").Click(x => x.Code);
            UltiPro.Pages.TaxCodeContributionRate.NotSelected(x => x.AdditionalWageBaseCheckBox);
            UltiPro.Pages.TaxCodeContributionRate.ButtonBar.Click(x => x.Save);
            #endregion
        }

        [FixtureTearDown]
        public void FixtureTearDown()
        {
            UltiPro.Browser.Quit();
        }
    }
}
